﻿@using XRM.Security.WebUI.Consts
@{
    ViewBag.Title = "Отчеты";
    ViewBag.HideHeader = true;
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="panel-group" id="accordion">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="panel-title">
                <a data-toggle="collapse" href="#@ReportTypes.UserReport">Пользователи АИС</a>
            </h4>
        </div>
        <div id="@ReportTypes.UserReport" class="panel-collapse collapse">
            <div class="panel-body">
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="panel-title">
                <a data-toggle="collapse" href="#@ReportTypes.ExpireCertReport">Сертификаты, срок действия которых истекает</a>
            </h4>
        </div>
        <div id="@ReportTypes.ExpireCertReport" class="panel-collapse collapse">
            <div class="panel-body">
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="panel-title">
                <a data-toggle="collapse" href="#@ReportTypes.CertReport">Выданные и действующие сертификаты</a>
            </h4>
        </div>
        <div id="@ReportTypes.CertReport" class="panel-collapse collapse">
            <div class="panel-body">
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="panel-title">
                <a data-toggle="collapse" href="#@ReportTypes.DepartmentByScsiReport">Перечень учреждений, подключенных к защищенной системе передачи данных (с количеством СКЗИ в них)</a>
            </h4>
        </div>
        <div id="@ReportTypes.DepartmentByScsiReport" class="panel-collapse collapse">
            <div class="panel-body">
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="panel-title">
                <a data-toggle="collapse" href="#@ReportTypes.RequestByWorkKindReport">Перечень заявок (по видам работ)</a>
            </h4>
        </div>
        <div id="@ReportTypes.RequestByWorkKindReport" class="panel-collapse collapse">
            <div class="panel-body">
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="panel-title">
                <a data-toggle="collapse" href="#@ReportTypes.OpenRequestReport">Перечень невыполненных работ</a>
            </h4>
        </div>
        <div id="@ReportTypes.OpenRequestReport" class="panel-collapse collapse">
            <div class="panel-body">
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="panel-title">
                <a data-toggle="collapse" href="#@ReportTypes.ScsiReport">Журнал поэкземплярного учета СКЗИ</a>
            </h4>
        </div>
        <div id="@ReportTypes.ScsiReport" class="panel-collapse collapse">
            <div class="panel-body">
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $('.panel-collapse').on('shown.bs.collapse', function (e) {
        var panelContent = $(this).children();
        if (panelContent.children().size() != 0)
            return;
        
        panelContent.append("Загрузка формы...");
        $.ajax({
            url: "@Url.Action("LoadReportForm")",
            data: { reportType: e.currentTarget.id },
            success: function (result) {
                panelContent.html(result);
            }
        });
    });
    
    $(document).on('click', '.clearBtn', function () {
        clearForm($(this).closest('form'));
    });
    
    $(document).on('click', '.createReportBtn', function () {
        var btn = $(this);
        var form = btn.closest('form');
        btn.attr("data-loading-text", "Формирование...");
        btn.button("loading");
        $(".error-message", form).remove();
        $.post("@Url.Action("Create")", form.serialize(), function (result) {
            btn.button("reset");
            if (result.isSuccess) {
                location.href = result.url;
            } else {
                form.append($("<span class='error-message'>" + result.error + "</span>"));
            }
        });
    });
</script>